<include file="Public/head" title="个人资料"/>
<include file="Public/back_head"/>
<div class="main">
	<if condition="$address neq null">
		<foreach name="address" item="val">
	    <div class="url_list">
        <if condition="$Think.session.address neq null">
        <a href="{$Think.session.address}?address_id={$val.id}">
        <div class="top"><span>{$val.name}</span><span>{$val.phone}</span></div>
            <div class="bottom">{$val.area}{$val.address}</div>
        </a>
        <else/>
        <div class="top"><span>{$val.name}</span><span>{$val.phone}</span></div>
        <div class="bottom">{$val.area}{$val.address}</div>
        </if>
	        
	        <div class="url_select">
	            <div class="url_left" data-id="{$val.id}">
	                <i class="iconfont icon-yuan {:$val['is_default'] == '1'?'active':''}"></i>
	                设为默认地址
	            </div>
	            <div class="url_right">
	                <div class="add"><a href="{:U('address_save',array('id'=>$val['id']))}"><i class="iconfont icon-write"></i>编辑</a></div>
	                <div class="del"><a href="javascript:;" data-id="{$val.id}"><i class="iconfont icon-laji2"></i>删除</a></div>
	            </div>
	        </div>
	    </div>
	    </foreach>
    <else/>
    	<div class="certif_success">
	        <div class="tu"><img src="__PUBLIC__/home/image/icon2.png" alt=""></div>
	        <div class="title">抱歉，暂无收货地址！</div>
	        <div class="con">赶快去<a href="{:U('address_save')}">添加地址</a>吧~~</div>
	    </div>
    </if>
</div>
<div class="add_url_btn"><a href="{:U('address_save')}"><i class="iconfont icon-plus"></i>新建地址</a></div>
<script type="text/javascript">
$(function () {
    // 删除添加地址
    $(".del a").click(function (e) {
    	var obj = e.target;
    	var address_id = $(obj).attr('data-id');
    	confirm_dialog('确定删除该地址吗？',function(){
        	$.post("{:U('delete_address')}",{id:address_id},function(data){
        		layer.msg(data.info);
        		if(data.status == '1')setTimeout("location.reload()",1000);
        	});
        });
    });
    //设置默认地址
    $('.url_left').click(function(){
    	var address_id = $(this).attr('data-id');
    	$.post("{:U('default_address')}",{id:address_id},function(data){
//     		layer.msg(data.info);
    		if(data.status == '1')setTimeout("location.reload()",1000);
    	});
    });
})
</script>
<include file="Public/foot"/>